/**
 * @(#)com.framework.web.sys.service.UserService
 *
 * Copyright (c) 2014-2018 上海天跃科技有限公司
 *
 * DESC:
 *
 */
package com.framework.web.sys.service;

import com.framework.web.sys.domain.CodeCategory;
import com.framework.web.sys.repository.CodeCategoryRepository;
import com.framework.web.sys.repository.specifications.CodeCategorySpecs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

/**
 * @author fusf
 * @version 1.0  2016/1/8
 */
@Service
public class CodeCategoryService {

    @Autowired
    private CodeCategoryRepository codeCategoryRepository;

    /**
     * 新增或者保存
     * @param codeCategory
     * @return
     */
    public CodeCategory save(CodeCategory codeCategory) {
        return codeCategoryRepository.save(codeCategory);
    }

    /**
     * 删除
     * @param id
     */
    public void  delete(String id) {
        codeCategoryRepository.delete(id);
    }
    /**
     * 根据id查询
     * @param id
     * @return
     */
    public CodeCategory findById(String id) {
        return codeCategoryRepository.findOne(id);
    }


    /**
     * 分页查找
     * @param codeCategory
     * @param pr
     * @return
     */
    public Page<CodeCategory> getPageList(CodeCategory codeCategory, PageRequest pr) {
        Page<CodeCategory> totalList = codeCategoryRepository.findAll(
                CodeCategorySpecs.LikeCodeCategoryName(codeCategory), pr);
        return totalList;
    }












}
